package TCP3;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Send {
    public static void main(String[] args) throws IOException {
        System.out.println("客户端启动");
        Socket socket = new Socket(InetAddress.getLocalHost(),10100);
        OutputStream f1 = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(f1);
        Scanner sc=new Scanner(System.in);
        while(true){
            System.out.println("请输入要发送的消息：");
            String str=sc.nextLine();
            if(str.equals("exit")) {
                System.out.println("客户端退出");
                dos.close();
                socket.close();
                break;
            }
            dos.writeUTF(str);
            dos.flush();
        }
    }
}
